Skip to content

Instantly share code, notes, and snippets.

@beta
beta / SyntaxAnalyzer.java
Created December 2, 2015 12:20
SyntaxAnalyzer
package me.kyouko.syntaxanalyzer;
import java.util.ArrayList;
import java.util.List;
public class SyntaxAnalyzer {
String input;
List<Token> tokens;
@beta
beta / Lexer.java
Created November 14, 2015 12:52
A simple lexer for C programs.
package lexer;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class Lexer {
@Override
public void setCancelable(boolean cancelable) {
final Dialog dialog = getDialog();
View touchOutsideView = dialog.getWindow().getDecorView().findViewById(android.support.design.R.id.touch_outside);
View bottomSheetView = dialog.getWindow().getDecorView().findViewById(android.support.design.R.id.design_bottom_sheet);
if (cancelable) {
touchOutsideView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View bottomSheetView = getDialog().getWindow().getDecorView().findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheetView).setHideable(false);
private BottomSheetBehavior.BottomSheetCallback mBottomSheetCallback
= new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet,
@BottomSheetBehavior.State int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
dismiss();
}
}
<FrameLayout
android:id="@+id/design_bottom_sheet"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_gravity="center_horizontal|top"
  android:clickable="true"
  app:layout_behavior="@string/bottom_sheet_behavior"
  style="?attr/bottomSheetStyle"/>
View touchOutsideView = getDialog().getWindow().getDecorView().findViewById(android.support.design.R.id.touch_outside);
touchOutsideView.setOnClickListener(null);
private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) {
...
if (shouldWindowCloseOnTouchOutside()) {
coordinator.findViewById(R.id.touch_outside).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isShowing()) {
cancel();
}
<View
android:id="@+id/touch_outside"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:soundEffectsEnabled="false"/>
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}