-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from mhhollomon/refactor
Add semantic actions for rules
- Loading branch information
Showing
92 changed files
with
9,941 additions
and
20,924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--recurse=yes | ||
--exclude=build/* | ||
--exclude=extern/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
build | ||
build-* | ||
tags | ||
*.sublime-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# yalr | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
project(Yalr VERSION 0.03 | ||
DESCRIPTION "Yet another LR Parser Generator" | ||
LANGUAGES CXX) | ||
|
||
# | ||
# Make sure we use -std=c++17 or higher | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# | ||
# Set the default build type to Release (if the user doesn't specify) | ||
# | ||
set(default_build_type "Release") | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.") | ||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE | ||
STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
"Debug" "Release" "Developer" "CI") | ||
endif() | ||
|
||
|
||
add_compile_options("$<$<CONFIG:Developer>:-g;-O1;-Wall;-pedantic>") | ||
add_compile_options("$<$<CONFIG:CI>:-O1;-Wall;-pedantic>") | ||
add_compile_options("$<$<CONFIG:Release>:-O3>") | ||
|
||
add_subdirectory(extern) | ||
|
||
add_subdirectory(src) | ||
|
||
## | ||
## yalr application | ||
## | ||
add_executable(yalr) | ||
|
||
target_sources(yalr | ||
PRIVATE | ||
"src/main.cpp" | ||
) | ||
|
||
target_link_libraries(yalr | ||
PRIVATE | ||
lib-include | ||
translate_objlib | ||
analyzer_objlib | ||
parser_objlib | ||
tablegen_objlib | ||
codegen_objlib | ||
errorinfo_objlib | ||
sourcetext_objlib | ||
) | ||
|
||
# | ||
# Uses the yalr executable | ||
# | ||
add_subdirectory(examples) | ||
|
||
# | ||
# Testing | ||
# | ||
enable_testing() | ||
add_subdirectory(test) | ||
|
||
# | ||
# ctags | ||
# | ||
if(CMAKE_BUILD_TYPE STREQUAL "Developer") | ||
add_custom_target(ctags | ||
COMMAND ctags --options=${CMAKE_HOME_DIRECTORY}/.ctags -f ${CMAKE_BINARY_DIR}/tags . | ||
WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}" | ||
BYPRODUCTS tags | ||
VERBATIM | ||
COMMENT Generating ctags | ||
) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM alpine:edge | ||
RUN apk update && apk add g++ meson ninja clang cmake make | ||
RUN rm -rf /etc/apk/cache | ||
CMD [ "/usr/bin/env", "sh" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM archlinux/base:latest | ||
# I would prefer to use `pacman -Scc` | ||
# but packamn doesn't give you a way to force the deletion without | ||
# iteracting with te prompt. | ||
RUN pacman -Syu --noconfirm && pacman -S --noconfirm gcc clang cmake make && \ | ||
rm -rf /var/cache/pacman/pkg/* && rm -rf /var/lib/pacman/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM debian:unstable-slim | ||
RUN apt-get update && apt-get install -qq --assume-yes g++ meson ninja-build clang clang-tidy cmake && apt-get clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM mhhollomon/yalr-ci:alpine | ||
COPY . /tmp/ci-build | ||
WORKDIR /tmp/ci-build | ||
CMD ["./scripts/build.sh", "ci"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# JSON Data structure for the code template | ||
|
||
This document describes the layout of the JSON data used in the generating the code. | ||
|
||
## Overview | ||
|
||
The [inja](https://pantor.github.io/inja/) templating engine is used to render the final code. Inja uses JSON data - using the [nlohmann/json](https://github.com/nlohmann/json) library - to hold the values that will be inserted into the template. | ||
|
||
The main template resides in src/include/template.hpp. | ||
|
||
## Data Layout | ||
|
||
### Global | ||
|
||
- **namespace** : (scalar) The namespace to wrap the lexer and parser in. | ||
- **parserclass** : (scalar) The name to give the parser class | ||
- **lexerclass** : (scalar) The name to give the lexer class | ||
|
||
### Lexer related data | ||
|
||
- **enums** : (array) the list of tokens | ||
- **name** : (scalar) the name of the enum entity | ||
- **value** : (scalar) the value to give the entity | ||
- **types** : (array) list of type names. Used to create the values variant. | ||
- **semantic_actions** : (array) data related to terminal's actions. | ||
- **token** : (scalar) Token that owns the action. | ||
- **block** : (scalar) Actual code for the action. | ||
- **type** : (scalar) Type of the expected returned value. | ||
- **patterns** : (array) Data surround the matching logic for terms and skips. | ||
- **matcher** : (scalar) The type of matcher - string or regex. | ||
- **pattern** : (scalar) The actual thing to match. | ||
- **token** : (scalar) The token that owns the match. | ||
|
||
### Parser related data | ||
|
||
- **states** : (array) The data for each state | ||
- **id** : (scalar) The numeric id of the state. | ||
- **actions** : (array) the actions for the state. | ||
- **type** : (scalar) type of action, reduce, shift, accept | ||
- **prodid** : (r, scalar) Numeric id of the production. | ||
- **production** : (r, scalar) string describing the prod for a reduce | ||
- **count** : (r, scalar) Number of items in the production | ||
- **returnlevels** : (r, scalar) Number of levels to skip in the return | ||
- **symbol** : (r, scalar) Name of Token for the rule | ||
- **valuetype** : (r, scalar) Type string (e.g. 'int', etc). | ||
- **hasvaluetype** : (r, scalar) Boolean - is the valuetype not 'void' | ||
- **hassemaction** : (r, scalar) Boolean - prod has a semantic action. | ||
- **newstateid** : (s, scalar) For shift, the number of next state to enter | ||
- **gotos** : (array) The gotos for the state | ||
- **symbol** : (scalar) The token name of the look ahead symbol | ||
- **stateid** : (scalar) The numeric id of the new state. | ||
- **reducefuncs** : (array) The data for each reduce function | ||
- **prodid** : (scalar) Numeric id of the production. | ||
- **itemtypes** : (array) List of item types for this production. | ||
- **block** : (scalar) actual code for the action. | ||
- **production** : (scalar) string describing the prod for this reduce | ||
- **rule_type** : (scalar) type (eg. int, void) of the rule for this production. |
Oops, something went wrong.